{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style>\n",
       "        .output_wrapper, .output {\n",
       "            height:auto !important;\n",
       "            max-height:100000px;\n",
       "        }\n",
       "        .output_scroll {\n",
       "            box-shadow:none !important;\n",
       "            webkit-box-shadow:none !important;\n",
       "        }\n",
       "        </style>\n",
       "    "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import sys\n",
    "sys.path.insert(0,'..') # allow us to format the book\n",
    "\n",
    "# use same formatting as rest of book so that the plots are\n",
    "# consistant with that look and feel.\n",
    "import book_format\n",
    "book_format.set_style()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgQAAAFlCAYAAACUQvD0AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/d3fzzAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAujklEQVR4nO3deXxU9b3/8fdkm5CQhSRksm+sgciSACGBAG6xuFyp3oq1FQVsm2pF4NqHIr9Hq157c9veer29NihlUaxFahWkliqxV/YoEBNQiGwhG2QhAbIAmSQz5/dHYDQNsSQkTEhez8dj/pjvnMP5zAFm3vM93/P9mgzDMAQAAPo1F2cXAAAAnI9AAAAACAQAAIBAAAAARCAAAAAiEAAAABEIAACACAQAAEAEAgAAIAIBAABQFwLBtm3bdNdddyksLEwmk0kbNmz4p/ts3bpVSUlJ8vT0VFxcnF555ZWu1AoAAHpIpwPBuXPnNHbsWL388stXtP3x48d1++23Ky0tTXl5eXrmmWe0YMECvfPOO50uFgAA9AzT1SxuZDKZtH79es2aNavDbZ566ilt3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c8//1wpKSlqbGzUwIEDtX79eo0aNcrZZTndW2+9pdzcXO3du9fZpfQ6ycnJWrNmjYYPH67Kykq98MILSk1N1YEDBzpcwKy/KCws1LJly7R48WI988wz2r17txYsWCCz2dxmivf+bsOGDTp79qwefvhhZ5fSKzz11FOqra3VyJEj5erqKpvNpl/84hf67ne/27MHNvqxRx991IiOjjZKS0udXUqvYbVajSNHjhh79uwxnn76aSMoKMg4cOCAs8tyqpKSEiM4ONjIz893tE2fPt144oknnFdUL9bQ0GBYLBbjN7/5jbNLcTp3d3cjJSWlTdvjjz9uTJ482UkV9U7p6enGnXfe6ewyeo21a9caERERxtq1a439+/cba9asMQICAozXXnutR4/bbwPBT37yEyMiIsIoLCx0dim92s0332z88Ic/dHYZTrV+/XpDkuHq6up4SDJMJpPh6upqtLS0OLvEXueWW24xMjIynF2G00VFRRnz589v05aVlWWEhYU5qaLep6ioyHBxcTE2bNjg7FJ6jYiICOPll19u0/bv//7vxogRI3r0uP3ukoFhGHr88ce1fv16bdmyRbGxsc4uqVczDENWq9XZZTjVzTffrM8//7xN29y5czVy5Eg99dRTjKj/B1arVQUFBUpLS3N2KU43ZcqUdrc1Hz582LEYHKTVq1crODhYd9xxh7NL6TXOnz8vF5e2Q/xcXV257bC7PfbYY/rjH/+o9957Tz4+PqqoqJAk+fn5acCAAU6uzrmeeeYZzZw5U5GRkaqvr9dbb72lLVu26IMPPnB2aU7l4+PTboyJt7e3AgMDGXsi6cknn9Rdd92lqKgoVVVV6YUXXlBdXZ0eeughZ5fmdIsWLVJqaqr+4z/+Q/fdd592796t5cuXa/ny5c4urVew2+1avXq1HnroIbm59buvow7ddddd+sUvfqGoqCiNHj1aeXl5evHFFzVv3ryePXCP9j/0QpIu+1i9erWzS3O6efPmGdHR0YaHh4cxePBg4+abbzY2b97s7LJ6JcYQfGX27NlGaGio4e7uboSFhRn33HNPvx938nV/+ctfjISEBMNsNhsjR440li9f7uySeo0PP/zQkGQcOnTI2aX0KnV1dcYTTzxhREVFGZ6enkZcXJyxdOlSw2q19uhx+/08BAAAgHkIAACACAQAAEAEAgAAIAIBAAAQgQAAAIhAAAAARCAAAAAiEAAAABEIAACACAQAAEAEAgAAIAIBAACQ9P8BqS4s+Y+pkQEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 600x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from kf_book.gif_animate import animate\n",
    "from stats import gaussian\n",
    "import matplotlib.pylab as pylab\n",
    "from matplotlib import animation\n",
    "import matplotlib\n",
    "\n",
    "def plt_g (mu, variance):\n",
    "    xs = np.arange(2,8,0.05)\n",
    "    ys = [gaussian (x, mu, variance) for x in xs]\n",
    "    plt.plot (xs, ys)\n",
    "    plt.ylim((0,1))\n",
    "\n",
    "\n",
    "mu = 2\n",
    "sigma = 0.6\n",
    "def ganimate(frame):\n",
    "    global mu, sigma\n",
    "    if frame < 25:\n",
    "        mu += .2\n",
    "    elif frame == 25:\n",
    "        mu = 5\n",
    "    elif frame < 37:\n",
    "        sigma -= 0.05\n",
    "    else:\n",
    "        sigma += 0.05\n",
    "\n",
    "    plt.cla()\n",
    "    plt_g(mu,sigma)\n",
    "\n",
    "animate('04_gaussian_animate.gif', ganimate, \n",
    "        frames=80, interval=50, figsize=(6,4))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src='04_gaussian_animate.gif'>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
